<@t.header> </@t.header> <@t.body>
	<div class="navbar navbar-default navbar-fixed-top padding-0 margin-0">
		<div class="navbar-header">
			<a class="navbar-brand" href="#" style="border-right: 1px solid #ddd;">
				<i class="icon-flag" style="color:#11e;"></i>
				pH
			</a>
		</div>
		<ul class="nav navbar-nav suredy-form-bar" id="btList">
			<a class="navbar-brand" href="#" id="btn-ok">
				<i class="icon-ok"></i> 完成
			</a>			
			<a class="navbar-brand" href="#" id="btn-save">
				<i class="icon-save"></i> 保存
			</a>		
		</ul>
		<ul class="nav navbar-nav navbar-right">
			<li>
				<a href="#" class="suredy-close-form">
					<i class="icon-remove close" style="margin-right: 10px;"></i>
				</a>
			</li>
		</ul>
	</div>
	<div class="container suredy-form" style="margin-top:50px;">
		<div class="panel-body">
			<#if phvalue??>
				<form name="form" id="form">	
					<input type="hidden" name="id" id="id" value="${phvalue.id}" />
					<input type="hidden" name="ctrlInfo" id="ctrlInfo">
					<input type="hidden" name="ESID" id="ESID" value="${Session['flow_session'].sessionId}">
					<input type="hidden" name="processId" id="processId" value="${phvalue.processId}">
					<input type="hidden" name="createTime" id="createTime" value="${phvalue.createTime}">
					<input type="hidden" name="fileType" id="fileType" value="test">
					<input type="hidden" name="fileTypeCode" id="fileTypeCode" value="${phvalue.fileTypeCode}">
					<input type="hidden" name="creatorCode" id="creatorCode" value="${phvalue.creatorCode}">
					<input type="hidden" name="creatorUnitCode" id="creatorUnitCode" value="${phvalue.creatorUnitCode}">
					<input type="hidden" name="title" id="title" value="pH"/>
					<table width="100%" class="table">
						<tr>
							<td width="10%" class="text-right" style="border:0px; line-height:100%; vertical-align: middle;">采样日期</td>
							<td width="40%" style="border:0px;"><input type="text" class="form-control datetimepicker" id="sampleDate" name="sampleDate" data-time="${phvalue.sampleDate}" data-format="yyyy-MM-dd"/></td>
							<td width="10%" class="text-right" style="border:0px; line-height:100%; vertical-align: middle;">检测日期</td>
							<td width="40%" style="border:0px;"><input type="text" class="form-control datetimepicker" id="detectionDate" name="detectionDate" data-time="${.now}" data-format="yyyy-MM-dd"/></td>
						</tr>
						<tr>
							<td class="text-right" style="border:0px; line-height:100%; vertical-align: middle;">室内温度℃</td>
							<td style="border:0px;"><input type="text" class="form-control" id="temerature" name="temerature" placeholder="室内温度" value="${(phvalue.temerature)!''}" /></td>
							<td class="text-right" style="border:0px; line-height:100%; vertical-align: middle;">室内湿度%</td>
							<td style="border:0px;"><input type="text" class="form-control" id="humidity" name="humidity" placeholder="室内湿度" value="${(phvalue.humidity)!''}"/></td>
						</tr>
					</table>
	
					<table class="table table-bordered">
						<tr>
							<td width="20%" class="text-right" style="line-height:100%; vertical-align: middle;">检测项目</td>
							<td width="80%"><input type="text" class="form-control" id="detectionName" name="detectionName" value="${(phvalue.detectionName)!'pH'}" /></td>
						</tr>
						<tr>
							<td class="text-right" style="line-height:100%; vertical-align: middle;">检测方法</td>
							<td><input type="text" class="form-control" id="method" name="method" value="${(phvalue.method)!'玻璃电极法'}" /></td>
						</tr>
						<tr>	
							<td class="text-right" style="line-height:100%; vertical-align: middle;">方法依据</td>
							<td><input type="text" class="form-control" id="standards" name="standards" value="${(phvalue.method)!'GB/T5750.4-2006中的5.1'}" /></td>
						</tr>						
						
						<tr>
							<td class="text-right" style="line-height:100%; vertical-align: middle;">备注</td>
							<td><textarea rows="3" class="form-control" type="text" name="comments" placeholder="备注">${(phvalue.comments)!''}</textarea></td>
						</tr>
					</table>
						
					<table width="100%" id="items-list" class="table table-striped table-bordered table-hover">
						<tr class="title-row">
							<th width="40%">样品编号</th>
							<th width="40%">检测结果</th>
							<th width="20%" class="text-center">操作</th>
						</tr>
						<#if phvalue.items ??><#list phvalue.items as item>
							<tr>
								<td><input type="hidden" name="item_id" value="${item.id}" /><input type="text" class="form-control" name="sampleId" value="${item.sampleId}" /></td>
								<td><input type="text" class="form-control" name="detectionValue" ${(1==item.deprecated)?string('readonly=\"readonly\"','')}  value="${item.detectionValue}" /><input type="hidden" name="deprecated" value="${item.deprecated!'0'}" /></td>
								<td>
									<div class="btn btn-info redoItem"> 
										<i class="icon-undo"></i> 重做此项
									</div>
								</td>
							</tr>
						</#list></#if>																							
					</table>
											
					<table width="100%" class="table">
						<tr>
							<td width="10%" class="text-right" style="border:0px; line-height:100%; vertical-align: middle;">检测人</td>
							<td width="40%" style="border:0px;">
								<input type="text" readonly="readonly" class="form-control" id="detectorName" name="detectorName" value="${Session['login_user'].name}" />
								<input type="hidden" id="detector" name="detector" value="${Session['login_user'].id}" />
							</td>
							<td width="10%" class="text-right" style="border:0px; line-height:100%; vertical-align: middle;">审核人</td>
							<td width="40%" style="border:0px;"><input type="text" class="form-control" readonly="readonly" id="auditorName" name="auditorName"  /></td>
						</tr>
						<tr>
							<td colspan="4" class="text-right" style="border:0px; line-height:100%; vertical-align: middle;">昆明清源自来水有限责任公司水质</td>
						</tr>
						<tr>
							<td colspan="4" class="text-right" style="border:0px; line-height:100%; vertical-align: middle;">表单编号:KMQY06D-JL-T-003</td>
						</tr>						
					</table>		
				</form>
			</#if>
			<div class="col-md-12 col-xs-12" id="comment-content"></div>															
		</div>	
		
	</div>
</@t.body> <@t.foot>
	
	<script src="${request.contextPath}/core/js/flow-core.js"></script>
	<script src="${request.contextPath}/core/js/jquery.form.js"></script>
	<script src="${request.contextPath}/js/suredy-datetimepicker.js"></script>
	<script src="${request.contextPath}/js/flow-app.js"></script>
	<script src="${request.contextPath}/js/suredy-modal.js"></script>
	
	<script src="${request.contextPath}/component/flow/js/sender.js"></script>
	<script src="${request.contextPath}/component/flow/js/comment.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {	
			initForm();
			$.suredy.datetimepicker.init();				
						
			$('.redoItem').click(function() {
				var source = $(this).parent().parent();
				var tr = source.clone();
				tr.children('td').eq(0).children('input').eq(0).val('');
				tr.children('td').eq(1).children('input').eq(1).val('0');
				source.children('td').eq(1).children('input').eq(0).attr('readonly', 'readonly');
				source.children('td').eq(1).children('input').eq(1).val('1');
				tr.children('td').eq(3).html('');
				tr.insertAfter('#items-list tr:eq('+ source.index() +')');
			});
			
			$('#btn-save').click(function() {
			/*
				$('#items-list tr:not(:first)').each(function(){
					var index = $(this).index() - 1;
					$(this).children('td').each(function(){
						$(this).children('input').each(function(){
							var name = $(this).attr('name');
							$(this).attr('name', 'items[' + index + '].' + name);
						});
					});
	            });			
			*/	
				
				$('#form').ajaxSubmit({
					url : $.suredy.contextPath + '/app/detection/phvalue-edit',
					dataType : 'json',
					type : 'POST',
					success : function(success) {
						if (!success) {
							alert('保存pH检测任务失败！');
						} else if (!success.success) {
							alert('保存pH检测任务失败！\n\n' + success.msg);
						} else {
							alert('保存pH检测任务成功！');
						}
					},
					error : function(a, b, c) {
						alert('服务器错误! ' + c);
					}
				});				
				

							
			});
		});
		function saveForm() {	
	
		}
	</script>	
</@t.foot>
